package com.jinsi.controller.zhu;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;

/**
 * 展示系统信息
 * @author 朱浩榕
 * @Date 2022-10-13
 */
@RestController
@RequestMapping("/computerinfo")
@Slf4j
public class ComputerController {
    /**
     * 获得本机展示
     * @return
     */
    @RequestMapping("/getshow")
    public static Map getUserInfo(){
        Map map = new HashMap();
        try{
            String userName = System.getProperty("user.name");
            String userHome = System.getProperty("user.home");
            String userDir = System.getProperty("user.dir");
            InetAddress ip = InetAddress.getLocalHost();
            String localName = ip.getHostName();
            String osName = System.getProperty("os.name");
            String osVersion = System.getProperty("os.version");
            String osArch = System.getProperty("os.arch");

            map.put("userName",userName);
            map.put("userHome",userHome);
            map.put("userDir",userDir);
            map.put("ip",ip);
            map.put("localName",localName);
            map.put("osName",osName);
            map.put("osArch",osArch);
            map.put("osVersion",osVersion);
//            System.out.println("当前用户：" + userName);
//            System.out.println("用户主目录："+ userHome);
//            System.out.println("当前工作目录："+ userDir);
//            System.out.println("当前用户：" + userName);
////            System.out.println("用户的主目录："+props.getProperty("user.home"));
////            System.out.println("用户的当前工作目录："+props.getProperty("user.dir"));
//            System.out.println("主机名称：" + localName);
//            System.out.println("主机系统：" + osName);
//            System.out.println("系统版本：" + osVersion);
//            System.out.println("系统架构：" + osArch);
//            System.out.println(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }
}
